package com.leve.admin.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Transient;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;
import java.util.Set;

@ApiModel("时间轴中嵌入的评论")
@Data
public class EmbeddedComment {
    @ApiModelProperty(value = "标识", readOnly = true)
    @Null
    private String id;

    @ApiModelProperty(position = 1, value = "被评论的此刻标识", readOnly = true)
    @Size(max = 64)
    private String postId;

    @ApiModelProperty(position = 2, value = "被回复的用户标识")
    @Size(max = 64)
    private String replyTo;

    @ApiModelProperty(position = 3, value = "评论文字", required = true, allowableValues = "range[1,200]")
    @NotBlank
    @Size(min = 1, max = 200)
    private String text;

    @ApiModelProperty(position = 4, value = "点赞总数", readOnly = true)
    private Integer totalVoters;

    @ApiModelProperty(position = 5, value = "点赞用户标识")
    @JsonIgnore
    private Set<String> voterIds;

    @ApiModelProperty(position = 6, value = "二级评论总数", readOnly = true)
    private Integer totalReplies;

    @ApiModelProperty(position = 7, value = "二级评论", readOnly = true)
    private List<Reply> replies;

    @ApiModelProperty(position = 8, value = "用户", required = true)
    @Valid
    @NotNull
    private User user;

    @ApiModelProperty(position = 9, value = "创建日期时间", readOnly = true)
    @CreatedDate
    private Date createdDate;

    @ApiModelProperty(position = 10, value = "查询者是否点过赞", readOnly = true)
    @Transient
    private Boolean voted;

}
